Double

class Double : Number, Comparable<Double>

Represents a double-precision 64-bit IEEE 754 floating point number. On the JVM, non-nullable values of this type are represented as values of the primitive type double.

Types

Companion
Link copied to clipboard
object Companion

Functions

compareTo
Link copied to clipboard
operator fun compareTo(other: Byte): Int
open operator override fun compareTo(other: Double): Int
operator fun compareTo(other: Float): Int
operator fun compareTo(other: Int): Int
operator fun compareTo(other: Long): Int
operator fun compareTo(other: Short): Int

Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other.

dec
Link copied to clipboard
operator fun dec(): Double

Decrements this value.

div
Link copied to clipboard
operator fun div(other: Byte): Double
operator fun div(other: Double): Double
operator fun div(other: Float): Double
operator fun div(other: Int): Double
operator fun div(other: Long): Double
operator fun div(other: Short): Double

Divides this value by the other value.

inc
Link copied to clipboard
operator fun inc(): Double

Increments this value.

minus
Link copied to clipboard
operator fun minus(other: Byte): Double
operator fun minus(other: Double): Double
operator fun minus(other: Float): Double
operator fun minus(other: Int): Double
operator fun minus(other: Long): Double
operator fun minus(other: Short): Double

Subtracts the other value from this value.

plus
Link copied to clipboard
operator fun plus(other: Byte): Double
operator fun plus(other: Double): Double
operator fun plus(other: Float): Double
operator fun plus(other: Int): Double
operator fun plus(other: Long): Double
operator fun plus(other: Short): Double

Adds the other value to this value.

rem
Link copied to clipboard
operator fun rem(other: Byte): Double
operator fun rem(other: Double): Double
operator fun rem(other: Float): Double
operator fun rem(other: Int): Double
operator fun rem(other: Long): Double
operator fun rem(other: Short): Double

Calculates the remainder of truncating division of this value by the other value.

Since Kotlin

1.1
times
Link copied to clipboard
operator fun times(other: Byte): Double
operator fun times(other: Double): Double
operator fun times(other: Float): Double
operator fun times(other: Int): Double
operator fun times(other: Long): Double
operator fun times(other: Short): Double

Multiplies this value by the other value.

toByte
Link copied to clipboard
@DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5")
open override fun toByte(): Byte

Converts this Double value to Byte.

toChar
Link copied to clipboard
@DeprecatedSinceKotlin(warningSince = "1.5")
open override fun toChar(): Char

Converts this Double value to Char.

toDouble
Link copied to clipboard
open override fun toDouble(): Double

Returns this value.

toFloat
Link copied to clipboard
open override fun toFloat(): Float

Converts this Double value to Float.

toInt
Link copied to clipboard
open override fun toInt(): Int

Converts this Double value to Int.

toLong
Link copied to clipboard
open override fun toLong(): Long

Converts this Double value to Long.

toShort
Link copied to clipboard
@DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5")
open override fun toShort(): Short

Converts this Double value to Short.

unaryMinus
Link copied to clipboard
operator fun unaryMinus(): Double

Returns the negative of this value.

unaryPlus
Link copied to clipboard
operator fun unaryPlus(): Double

Returns this value.

Extensions

absoluteValue
Link copied to clipboard
val Double.absoluteValue: Double
val Double.absoluteValue: Double
val Double.absoluteValue: Double
val Double.absoluteValue: Double

Returns the absolute value of this value.

coerceAtLeast
Link copied to clipboard
Common
fun Double.coerceAtLeast(minimumValue: Double): Double

Ensures that this value is not less than the specified minimumValue.

coerceAtMost
Link copied to clipboard
Common
fun Double.coerceAtMost(maximumValue: Double): Double

Ensures that this value is not greater than the specified maximumValue.

coerceIn
Link copied to clipboard
Common
fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double

Ensures that this value lies in the specified range minimumValue..maximumValue.

days
Link copied to clipboard
Common
val Double.days: Duration

Returns a Duration equal to this Double number of days.

hours
Link copied to clipboard
Common
val Double.hours: Duration

Returns a Duration equal to this Double number of hours.

IEEErem
Link copied to clipboard
inline fun Double.IEEErem(divisor: Double): Double

Computes the remainder of division of this value by the divisor value according to the IEEE 754 standard.

Native
external fun Double.IEEErem(divisor: Double): Double

Computes the remainder of division of this value by the divisor value according to the IEEE 754 standard.

isFinite
Link copied to clipboard
Common
fun Double.isFinite(): Boolean
inline fun Double.isFinite(): Boolean
fun Double.isFinite(): Boolean
external fun Double.isFinite(): Boolean

Returns true if the argument is a finite floating-point value; returns false otherwise (for NaN and infinity arguments).

isInfinite
Link copied to clipboard
Common
fun Double.isInfinite(): Boolean
inline fun Double.isInfinite(): Boolean
fun Double.isInfinite(): Boolean
external fun Double.isInfinite(): Boolean

Returns true if this value is infinitely large in magnitude.

isNaN
Link copied to clipboard
Common
fun Double.isNaN(): Boolean
inline fun Double.isNaN(): Boolean
fun Double.isNaN(): Boolean
external fun Double.isNaN(): Boolean

Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

microseconds
Link copied to clipboard
Common
val Double.microseconds: Duration

Returns a Duration equal to this Double number of microseconds.

milliseconds
Link copied to clipboard
Common
val Double.milliseconds: Duration

Returns a Duration equal to this Double number of milliseconds.

minutes
Link copied to clipboard
Common
val Double.minutes: Duration

Returns a Duration equal to this Double number of minutes.

mod
Link copied to clipboard
Common
inline fun Double.mod(other: Float): Double
inline fun Double.mod(other: Double): Double

Calculates the remainder of flooring division of this value by the other value.

nanoseconds
Link copied to clipboard
Common
val Double.nanoseconds: Duration

Returns a Duration equal to this Double number of nanoseconds.

nextDown
Link copied to clipboard
Common
fun Double.nextDown(): Double

Returns the Double value nearest to this value in direction of negative infinity.

inline fun Double.nextDown(): Double

Returns the Double value nearest to this value in direction of negative infinity.

JS
fun Double.nextDown(): Double

Returns the Double value nearest to this value in direction of negative infinity.

Native
external fun Double.nextDown(): Double

Returns the Double value nearest to this value in direction of negative infinity.

nextTowards
Link copied to clipboard
Common
fun Double.nextTowards(to: Double): Double

Returns the Double value nearest to this value in direction from this value towards the value to.

inline fun Double.nextTowards(to: Double): Double

Returns the Double value nearest to this value in direction from this value towards the value to.

JS
fun Double.nextTowards(to: Double): Double

Returns the Double value nearest to this value in direction from this value towards the value to.

Native
external fun Double.nextTowards(to: Double): Double

Returns the Double value nearest to this value in direction from this value towards the value to.

nextUp
Link copied to clipboard
Common
fun Double.nextUp(): Double

Returns the Double value nearest to this value in direction of positive infinity.

inline fun Double.nextUp(): Double

Returns the Double value nearest to this value in direction of positive infinity.

JS
fun Double.nextUp(): Double

Returns the Double value nearest to this value in direction of positive infinity.

Native
external fun Double.nextUp(): Double

Returns the Double value nearest to this value in direction of positive infinity.

pow
Link copied to clipboard
fun Double.pow(x: Double): Double
inline fun Double.pow(x: Double): Double
inline fun Double.pow(x: Double): Double
external fun Double.pow(x: Double): Double

Raises this value to the power x.

fun Double.pow(n: Int): Double
inline fun Double.pow(n: Int): Double
inline fun Double.pow(n: Int): Double
fun Double.pow(n: Int): Double

Raises this value to the integer power n.

rangeTo
Link copied to clipboard
Common
operator fun Double.rangeTo(that: Double): ClosedFloatingPointRange<Double>

Creates a range from this Double value to the specified that value.

roundToInt
Link copied to clipboard
Common
fun Double.roundToInt(): Int

Rounds this Double value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

fun Double.roundToInt(): Int

Rounds this Double value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

JS
fun Double.roundToInt(): Int

Rounds this Double value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

Native
fun Double.roundToInt(): Int

Rounds this Double value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

roundToLong
Link copied to clipboard
Common
fun Double.roundToLong(): Long

Rounds this Double value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

fun Double.roundToLong(): Long

Rounds this Double value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

JS
fun Double.roundToLong(): Long

Rounds this Double value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

Native
fun Double.roundToLong(): Long

Rounds this Double value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

seconds
Link copied to clipboard
Common
val Double.seconds: Duration

Returns a Duration equal to this Double number of seconds.

sign
Link copied to clipboard
val Double.sign: Double
val Double.sign: Double
val Double.sign: Double
val Double.sign: Double

Returns the sign of this value:

times
Link copied to clipboard
Common
inline operator fun Double.times(duration: Duration): Duration

Returns a duration whose value is the specified duration value multiplied by this number.

toBigDecimal
Link copied to clipboard
inline fun Double.toBigDecimal(): BigDecimal
inline fun Double.toBigDecimal(mathContext: MathContext): BigDecimal

Returns the value of this Double number as a BigDecimal.

toBits
Link copied to clipboard
Common
fun Double.toBits(): Long

Returns a bit representation of the specified floating-point value as Long according to the IEEE 754 floating-point "double format" bit layout.

inline fun Double.toBits(): Long

Returns a bit representation of the specified floating-point value as Long according to the IEEE 754 floating-point "double format" bit layout.

JS
fun Double.toBits(): Long

Returns a bit representation of the specified floating-point value as Long according to the IEEE 754 floating-point "double format" bit layout.

Native
inline fun Double.toBits(): Long

Returns a bit representation of the specified floating-point value as Long according to the IEEE 754 floating-point "double format" bit layout.

toDuration
Link copied to clipboard
Common
fun Double.toDuration(unit: DurationUnit): Duration

Returns a Duration equal to this Double number of the specified unit.

toRawBits
Link copied to clipboard
Common
fun Double.toRawBits(): Long

Returns a bit representation of the specified floating-point value as Long according to the IEEE 754 floating-point "double format" bit layout, preserving NaN values exact layout.

inline fun Double.toRawBits(): Long

Returns a bit representation of the specified floating-point value as Long according to the IEEE 754 floating-point "double format" bit layout, preserving NaN values exact layout.

JS
fun Double.toRawBits(): Long

Returns a bit representation of the specified floating-point value as Long according to the IEEE 754 floating-point "double format" bit layout, preserving NaN values exact layout.

Native
inline fun Double.toRawBits(): Long

Returns a bit representation of the specified floating-point value as Long according to the IEEE 754 floating-point "double format" bit layout, preserving NaN values exact layout.

toUInt
Link copied to clipboard
Common
inline fun Double.toUInt(): UInt

Converts this Double value to UInt.

toULong
Link copied to clipboard
Common
inline fun Double.toULong(): ULong

Converts this Double value to ULong.

ulp
Link copied to clipboard
val Double.ulp: Double
val Double.ulp: Double
val Double.ulp: Double
val Double.ulp: Double

Returns the ulp (unit in the last place) of this value.

withSign
Link copied to clipboard
fun Double.withSign(sign: Double): Double
fun Double.withSign(sign: Int): Double
inline fun Double.withSign(sign: Double): Double
inline fun Double.withSign(sign: Int): Double
fun Double.withSign(sign: Double): Double
inline fun Double.withSign(sign: Int): Double
external fun Double.withSign(sign: Double): Double
fun Double.withSign(sign: Int): Double

Returns this value with the sign bit same as of the sign value.